package cn.wolfcode.p2p.base.domain;

import com.alibaba.druid.support.json.JSONUtils;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.text.DateFormat;
import java.util.Date;
import java.util.HashMap;

/**
 * 实名认证对象
 */
@Getter
@Setter
public class RealAuth extends BaseAuditDomain {

    //性别
    private static final int SEX_MALE = 0;  // 男
    private static final int SEX_FEMALE = 0; //女

    private String realName;
    private Integer sex;
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date bornDate;
    private String idNumber;
    private String address;
    private String image1;
    private String image2;

    //显示性别
    public String getSexDisplay() {
        return sex == SEX_MALE ? "小哥哥" : "小姐姐";
    }

    /**
     * 模态框的值回显
     * @return
     */
    public String getJsonString(){
        HashMap<Object, Object> map = new HashMap<>();
        map.put("id",id);
        map.put("realName",realName);
        map.put("sex",getSexDisplay());
        map.put("idNumber",idNumber);
        map.put("address",address);
        map.put("state",getStateDisplay());
        map.put("image1",image1);
        map.put("image2",image2);
        map.put("bornDate", DateFormat.getDateInstance().format(bornDate));
        map.put("username",getApplier().getUsername());
        return JSONUtils.toJSONString(map);
    }




}